package com.gengdan.Test;

import com.gengdan.bean.SampleStorage;
import com.gengdan.service.SampleCollecService;
import com.gengdan.service.SampleStorageService;
import com.gengdan.service.UserInfoService;
import com.gengdan.util.Page;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:spring/spring-service.xml",
        "classpath*:spring/spring-dao.xml","classpath*:spring/spring-mvc.xml" })
public class TestDemo {
    @Autowired
    private SampleCollecService sampleCollecService;
    @Autowired
    private UserInfoService userInfoService;
    @Autowired
    private SampleStorageService sampleStorageService;
    @Test
    public void test1() {
        String str = "{[123:321,123:321]}";
        String out1 = str.substring(0,str.length()-1);
        String out2 = out1.substring(1);
        System.out.println(out2);
        System.out.println(out1);
    }

    @Test
    public void test2(){
        for(int i = 1;i<=2;i++) {
            String value = "delCountryId";
            String number = Integer.toString(i);
            String result = value.concat(number);
            System.out.println(result);
        }
    }

    @Test
    public void test3(){
//        System.out.println(userInfoService.selectPersonalInfo(1).toString());
//        String str="{\"delete\":[{\"sign1\":\"123\",\"sign2\":\" 345\"}]}";
        Page page = new Page();
        page.setStart(0);
        HashMap<String,Object> hm = sampleStorageService.selectSampleProcR2(page);
        System.out.println(hm.toString());
        for (int i=0;i<hm.size();i++){
            String value = (String) hm.get("userId");
            System.out.println(value);
        }

    }

    @Test
    public void test4() throws ParseException {
        String str = "2020-05-13 00:49:37";
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = sdf.parse(str);
        System.out.println(date.toString());
    }
}
